package com.hanrui.android.fragment.message.audit;

import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.hanrui.android.R;
import com.hanrui.android.adapter.ApproveAdapter;
import com.hanrui.android.library.base.BaseFragment;
import com.hanrui.android.model.ApproveListBean;
import com.hanrui.android.net.contract.message.audit.ApproveContract;
import com.hanrui.android.net.presenter.message.audit.ApprovePresenter;
import com.hanrui.android.widget.SearchEditText;

import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;

/**
 * 已办提醒列表
 *
 */
public class ChargeFragment extends BaseFragment<ApprovePresenter> implements ApproveContract.View {
    @BindView(R.id.searchEditText)
    SearchEditText searchEditText;
    @BindView(R.id.recyclerview_swipeLayout)
    SwipeRefreshLayout swipeLayout;
    @BindView(R.id.recyclerview)
    RecyclerView mRecyclerView;
    @Inject
    ApproveAdapter adapter;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_audit;
    }

    @Override
    protected void initInjector() {
        mFragmentComponent.inject(this);
    }

    @Override
    protected void initView(View view) {
        init();
    }


    public void init() {

//        swipeLayout.setRefreshing(true);
//        swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
//            @Override
//            public void onRefresh() {
//                mPresenter.refresh(mActivity);
//            }
//        });

        mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        mRecyclerView.setAdapter(adapter);
        adapter.setEmptyView(getNoDataView(mRecyclerView));
        adapter.setEnableLoadMore(false);

        adapter.setEmptyView(getNoDataView(mRecyclerView));

//        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
//            @Override
//            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
//                ApproveListBean.ListDataBean bean = (ApproveListBean.ListDataBean) adapter.getItem(position);
//
//                if (bean.getProcDefInfoKey().equals("process_oa_vehicle_use_apply")){//用车申请(已完成)
//                    ARouter.getInstance().build("/message/FlowActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_oa_meeting_apply")){ //会议申请(已完成)
//                    ARouter.getInstance().build("/message/meet/MeetBizActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_oa_reception_apply")){//接待申请（已完成）
//                    ARouter.getInstance().build("/message/reception/ReceptionActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if(bean.getProcDefInfoKey().equals("process_emp_on_leave")){ //请假申请(已完成)
//                    ARouter.getInstance().build("/message/empLeave/EmpLeaveActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if(bean.getProcDefInfoKey().equals("process_emp_sign_in_other")){//补打卡(已完成)
//                    ARouter.getInstance().build("/message/sign/SignActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_oa_dispatch_doc")){//发文(已完成)
//                    ARouter.getInstance().build("/message/dispatchDoc/DispathDocActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_oa_receipt_doc")){//收文（已完成）
//                    ARouter.getInstance().build("/message/receiptDoc/ReceiptDocActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_oa_card_record")){//油卡充值(已完成)
//                    ARouter.getInstance().build("/message/oil/OilActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_emp_leave_undo")){//销假（已完成）
//                    ARouter.getInstance().build("/message/leave/LeaveActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_emp_out_door_other") ||
//                        bean.getProcDefInfoKey().equals("process_emp_out_door_manager")){//外勤（已完成）
//                    ARouter.getInstance().build("/message/out/OutActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_emp_business_trip")){//出差(已完成)
//                    ARouter.getInstance().build("/message/out/OutActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_emp_quit")){//离职（已完成）
//                    ARouter.getInstance().build("/message/quit/QuitActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_oa_chapter_apply")){//用章（已完成）
//                    ARouter.getInstance().build("/message/chapter/ChapterActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_oa_vehicle_mtc_apply")){//车辆维保（已完成）
//                    ARouter.getInstance().build("/message/mtc/MtcActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_emp_transfer")){//人事人员调动(已完成)
//                    ARouter.getInstance().build("/message/transfer/TransferActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_oa_info_release_apply")){//多媒体（已完成）
//                    ARouter.getInstance().build("/message/release/ReleaseActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_oa_sign_doc")) {//签报单（已完成）
//                    ARouter.getInstance().build("/message/report/SignReportActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }else if (bean.getProcDefInfoKey().equals("process_oa_proposal")) {//议案（已完成）
//
//                    ARouter.getInstance().build("/message/motion/MotionActivity")
//                            .withString("taskId",bean.getTaskId())
//                            .withString("procInsId",bean.getProcInsId())
//                            .withString("meetingId",bean.getVars().getMap().getBusinessId())
//                            .withString("procDefInfoKey",bean.getProcDefInfoKey())
//                            .withString("businessId",bean.getVars().getMap().getBusinessId())
//                            .withString("assignee",bean.getAssignee())
//                            .navigation();
//                }
//
//
//
//
//            }
//        });

    }

    @Override
    public void onResume() {
        super.onResume();
//        mActivity.setRefreshing();
//        mPresenter.loadData(mActivity);
    }

    @Override
    public void loadData(List<ApproveListBean.ActListBean> dataList, int loadType) {

        setLoadDataResult(swipeLayout,adapter,dataList,loadType,false);
    }
}
